package com.xinsmartsky.penmaji.NewGridView;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by wangxiao on 15-12-25.
 */
public class Rect_angle implements Parcelable {
    private float sx, sy, ex, ey;
    private int alpha;//透明度
    private Paint paintt;

    public Rect_angle() {
    }

    protected Rect_angle(Parcel in) {
        sx = in.readFloat();
        sy = in.readFloat();
        ex = in.readFloat();
        ey = in.readFloat();
        alpha = in.readInt();
    }

    public static final Creator<Rect_angle> CREATOR = new Creator<Rect_angle>() {
        @Override
        public Rect_angle createFromParcel(Parcel in) {
            Rect_angle r = new Rect_angle();
            r.readFromParcel(in);
            return r;
        }

        @Override
        public Rect_angle[] newArray(int size) {
            return new Rect_angle[size];
        }
    };

    public void drawrect(Canvas canvas, Paint paint) {

        canvas.drawRect(sx, sy, ex, ey, paint);
    }

    public Rect_angle(float sx, float sy, float ex, float ey) {
        super();
        this.sx = sx;
        this.sy = sy;
        this.ex = ex;
        this.ey = ey;
    }

    public float getRectsx() {
        return sx;
    }

    public float getRectsy() {
        return sy;
    }

    public float getRectex() {
        return ex;
    }

    public float getRectey() {
        return ey;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeFloat(sx);
        dest.writeFloat(sy);
        dest.writeFloat(ex);
        dest.writeFloat(ey);
        dest.writeInt(alpha);
    }

    //哈希表
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Rect_angle r = (Rect_angle) o;
        return sx == r.sx && sy == r.sy && ex == r.ex && ey == r.ey;
    }

    @Override
    public int hashCode() {
        int result = (sx != +0.0f ? Float.floatToIntBits(sx) : 0);
        result = 31 * result + (sy != +0.0f ? Float.floatToIntBits(sy) : 0);
        result = 31 * result + (ex != +0.0f ? Float.floatToIntBits(ex) : 0);
        result = 31 * result + (ey != +0.0f ? Float.floatToIntBits(ey) : 0);
        return result;
    }

    public void readFromParcel(Parcel in) {
        sx = in.readFloat();
        sy = in.readFloat();
        ex = in.readFloat();
        ey = in.readFloat();
    }
}
